package com.ptszyxx.popose.module.main.ticket.vm;

import android.app.Application;

import androidx.annotation.NonNull;

import com.ptszyxx.popose.common.utils.YActivityUtil;
import com.ysg.base.BaseViewModel;
import com.ysg.binding.command.BindingCommand;
import com.ysg.http.BaseResponse;
import com.ysg.http.HttpUtils;
import com.ysg.http.callback.OnSuccessResult;
import com.ysg.http.data.CommonRepository;
import com.ysg.http.data.entity.user.UserResult;
import com.ysg.utils.YStringUtil;

import java.util.HashMap;
import java.util.Map;

public class RealDialogVM extends BaseViewModel<CommonRepository> {
    public boolean isJumped;

    public RealDialogVM(@NonNull Application application, CommonRepository model) {
        super(application, model);
    }

    public BindingCommand onRealCommand = new BindingCommand(() -> onJumpReal());

    /**
     * 用户信息
     */
    public void requestUser(){
        Map<String, String> map = new HashMap<>();
        HttpUtils.getInstance()
                .data(model.user(map), this,
                        new OnSuccessResult<UserResult>() {
                            @Override
                            public void onSuccessResult(BaseResponse<UserResult> response) {
                                //认证完成：关闭界面
                                if(YStringUtil.eq(2, response.getData().getIsReal())){
                                    YActivityUtil.getInstance().close(RealDialogVM.this);
                                }
                            }
                        });
    }

    private void onJumpReal() {
        YActivityUtil.getInstance().jumpMineReal(this);
        isJumped = true;
    }







}
